<?php defined('SYSPATH') OR die('No direct access allowed.'); ?>

<div id="" class="body_content">
 
	<h3><?=$this->crn?></h3>
	
	<center>
	<?=$pagination?>
	</center>
	
	<? foreach ($items as $key ){  ?>

		<div id="item" class="">
		
			<div id="" class="item_img">
			
				<? if (!empty($key->it_note1) && file_exists(SERVER_PATH.'avatars/'.$key->it_note1)) : ?>
				
					<a title="Увеличить изображение для <?=html::specialchars($key->it_model)?>" class="highslide" href="/avatars/<?=$key->it_note1?>" onclick="return hs.expand(this, { wrapperClassName: 'highslide-white', outlineType: 'rounded-white', dimmingOpacity: 0.75, align: 'center', captionText: '<?=$key->it_model?>' })">
						<img  src="/avatars_mini/<?=$key->it_note1?>"  title="Увеличить изображение <?=html::specialchars($key->it_model)?>" alt="Изображение для <?=html::specialchars($key->it_model)?>" border="0" />
					</a>	
				<? else : ?>
					<img  src="/avatars_mini/<?=$key->it_note1?>" title="<?=html::specialchars($key->it_model)?>" alt="<?=html::specialchars($key->it_model)?>" border="0" />
				<? endif ?>
			</div>
			
			<h4><?=wordwrap($key->it_model, 30, '<br/>')?></h4> 
			
			<div id="" class="item_desc"> 
				<? if (!empty($key->it_note2) && file_exists(SERVER_PATH.'desc/'.$key->it_note2)) : ?>
					<a href="/item:<?=$key->it_link?>" title="Более подробно о <?=html::specialchars($key->it_model)?>">Подробное описание</a><br/>
				<? endif ?>
				
				Фирма: <?=$key->fr_title?><br/>
				<?=$key->tp_title?><br/>
				
			</div>
			
			<div id="" class="item_price">
				<?=money($key->it_shop_price);?> <small>за <?=$key->it_metric?><br/>в магазине</small>
			</div> 
			
			<div id="link_<?=$key->it_id?>" class="ie6 <? if (@isset($items_ses[$key->it_id]) || @intval($items_ses[$key->it_size]) == 0) { echo 'item_desc'; } ?>">
				<? if(@intval($items_ses[$key->it_size]) != 0):  ?>
					Нет в наличии
				<? elseif (!isset($items_ses[$key->it_id])) : ?>
				
					<div id="order_item_<?=$key->it_id?>_it" class="count_it_edit" style="display: none;">
						Укажите количество:<br/>
						<input type="text" size="3" id="order_item_<?=$key->it_id?>_value" name="items" value=""></input> <a href="" title="" 
							onClick="$('#link_<?=$key->it_id?>').attr('innerHTML', RealEs.getItem('<?=$key->it_id?>', $('#order_item_<?=$key->it_id?>_value').val())).attr('className', 'item_desc' ); RealEs.order(0, <?=$key->it_id?>); return false;">Ok</a> | <a href="" title="" onClick="RealEs.order(0, <?=$key->it_id?>); return false;">Отмена</a>
					</div>
					
					<div id="order_item_<?=$key->it_id?>" class="count_it">
						<a href="#store_up" title="" onClick="RealEs.order(1, <?=$key->it_id?>); return false;">Отложить</a>
					</div>
				
				<? else : ?>
					Отложено
				<? endif ?>
				
			</div>
			
			<div id="" class="item_red_price">
				<?=money(formula($key))?>
			</div>
			
		</div>
		
	<? }?>
	
	<center>
	<?=$pagination?>
	 </center>
	
</div>
		</td>
		<td valign="top" style="width: 200px;">
 

<? if (intval($this->count_bin_items) > 0) : ?>
	
	<div id="first_rigth_block" class="body_bin_panel" style="margin-bottom: 20px;">

		 <h3 class="bin">Ваша корзина</h3> 
			
			
			<table width="100%" id="bin" cellspacing="0" cellpadding="5" >
		<!--
			<tr>
				<th>Наименование</th> 
				<th>Экономия</th> 
			
			</tr>//-->
	<? $counter = 1; $sum_internet = $sum_shop = $sum_econom = 0?>
	<?foreach ($bin_items as $key ){ ?>
		
		<? $internet_prise = formula($key); ?>
		<? if ($counter % 2 == 0) {$bg = '#f0f9fb';}else{$bg = '#FFFFFF';}; ?>
		<tr bgcolor="<?=$bg?>" id="item_id_<?=$key->it_id?>">
		
			<td style="text-align: left !important;">
			
				<div style="float: right"><small><?=$items_ses[$key->it_id].' '.$key->it_metric?> </small></div>
				<?=$key->it_model?> <small>(<?=$key->fr_title?>)</small>
				<div class="item_desc"><?=$key->tp_title?></div>
				
			</td> 
 
			<? $sum_internet += ($internet_prise * $items_ses[$key->it_id]) 
			; $sum_shop += ($key->it_shop_price * $items_ses[$key->it_id]) ?>
			
			<!--<td><?=money(($key->it_shop_price* $items_ses[$key->it_id]) - ($internet_prise* $items_ses[$key->it_id]) ); $sum_econom += ($key->it_shop_price* $items_ses[$key->it_id]) - ($internet_prise * $items_ses[$key->it_id]) ?></td> 
			//-->
		</tr>
		
		<? $counter ++;?>
		
	<?}?>
		
		<? if ($counter % 2 == 0) {$bg = '#f0f9fb';}else{$bg = '#FFFFFF';}; ?>
	
	</table>
<p><center><a title="" href="/bin">Изменить</a></center></p>
	<h3 class="bin">Цена</h3> 
	
	<table width="100%"  cellspacing="0" >
	
		<tr bgcolor="#f0f9fb">
	  
			<td>На сайте</td>  
			<td><?=money($sum_internet)?></td> 
		</tr>
		<tr bgcolor="#FFFFFF">
	  
			<td>В магазине</td>  
			<td><?=money($sum_shop)?></td> 
		</tr>
		<tr bgcolor="#f0f9fb">
	  
			<td>Экономия</td>  
			<td><?=money($sum_econom)?></td> 
		</tr>
	</table>

<p><center><a title="" href="/bin">Оформить</a></center></p>
	</div>
	<? $id = 'second_rigth_block'; ?>
<? else : ?>
	<? $id = 'first_rigth_block'; ?>
<? endif ?>

<div id="<?=$id?>" class="body_right_panel">
 
<? if (count($firms) > 1 && count($firms) > 1) : ?>
 
	<? if (count($types) > 1) : ?>
	Типы товаров:
		<ol id="nav">
			<? foreach ($types as $key ){  ?>
				<li><a title="Отфильтровать по типу товара: <?=html::specialchars($key->tp_title)?>" <? if($this->tp_id == $key->tp_link) { ?>id="selected"<? } ?> href="/products:<?=$this->id?>/type:<?=$key->tp_link?>" title=""><?=html::specialchars($key->tp_title)?></a></li>
			<? }?>
		</ol>
	<br/>
	<? endif ?>

	<? if (count($firms) > 1) : ?>
	Фирмы:
		<ol id="nav">
			<? foreach ($firms as $key ){  ?>
				<li><a title="Отфильтровать по фирме: <?=html::specialchars($key->fr_title)?>" <? if($this->fr_id == $key->fr_link) { ?>id="selected"<? } ?> href="/products:<?=$this->id?>/firm:<?=$key->fr_link?>" title=""><?=html::specialchars($key->fr_title)?></a></li>
			<? }?>
		</ol> 
	<? endif ?>
	
<? else : ?>

	<? 		
		$adv = new Adv_Model();
		echo $adv->getContent(); 
	?>
	
<? endif ?>
</div>